from divisors import sumOfDivisors

limit = 10000

sod = map(sumOfDivisors, xrange(limit))
print "built sod table for first", limit - 1, "natural numbers"

total = 0

for i in xrange(limit):
    isum = sod[i] 
    j = isum  
    if (i != j and j < limit):
        jsum = sod[j]
        if jsum == i:
            print i, "->", isum, j, "->", jsum
            total += i + j
            print total
            sod[j] = 0  # don't count it again

print total
    